<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/11/16
 * Time: 11:14
 */

namespace app\api\controller;


use app\common\controller\Api;
use think\Config;
use think\Request;
use app\api\Service\GameService;

class LotteryGame extends Api
{
    protected $noNeedLogin = [];
    protected $noNeedRight = ['*'];

    /**
     * 庄家选择英雄-玩家先选择
     * @param Request $request
     * @param GameService $gameService
     */
    public function bankerAndPk(Request $request,GameService $gameService)
    {
        $game = $request->get('game');//lol,dota2,pvp
        $player_1 = $request->get('player_1');//identifier 标识，玩家选取英雄
        $res = $gameService->banker($game,$player_1);
        if( $res['status'] == 200 ){
            $this->success($res['msg'],$res['data']);
        }
        $this->error($res['msg']);
    }

    /**
     * pk
     * @param GameService $gameService
     * @throws \Complex\Exception
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function pk(GameService $gameService)
    {
        $sequencenum = $this->request->post('sequencenum');
        $money = $this->request->post('money');

        $isBanker = $this->request->post('isBanker','Y'); //是否是庄家选择
        $res = $gameService->pk($sequencenum,$money,$isBanker);
        if( $res['status'] == 200 ){
            $this->success($res['msg'],$res['data']);
        }
        $this->error($res['msg']);
    }
}